﻿using System.Collections;
using System.Text;
using SimpleJSON;
using ROSBridgeLib.std_msgs;
using ROSBridgeLib.geometry_msgs;
using UnityEngine;
// Need geometry_msgs/PoseStamped[]

namespace ROSBridgeLib {
    
    namespace nav_msgs {
        
        public class OccupancyGrid : ROSBridgeMsg {
            
            public HeaderMsg _header;
            public MapMetaData info;

            public int[] data;

            public int width;

            public int height;

            public float resolution;

            public OccupancyGrid(JSONNode msg) {
                
                _header = new HeaderMsg(msg["header"]);

                info=new MapMetaData(msg["info"]);

                width=info.width;

                height=info.height;

                data=new int[width*height];

                resolution=info.resolution;

                JSONArray array=msg["data"].AsArray;
             
                int count=array.Count;

                for (int i=0;i<count;i++)
                {

                    int chance=array[i].AsInt;

                    data[i]=chance;

                }


            }

    
            public static string GetMessageType() {
                
                return "nav_msgs/OccupancyGrid";
             } 

         public HeaderMsg GetHeader() {
            return _header;
         } 


}
}
}
